<template>
  <div class="content">
    <div class="index-header-box" id="head">
      <div class="index-header">
        <div @click="$router.back(-1)" class="back">
          <van-icon name="arrow-left"/>
        </div>

        <div class="title">安全设置</div>
      </div>
    </div>
    <div class="rel-public-title">
      <span class="txt">设置密码</span>
    </div>
    <van-field type="password" class="input" v-model="pwd" label="输入密码" placeholder="请设置密码"  />
    <van-field type="password" class="input" v-model="pwd1" label="重复密码" placeholder="请重复密码"/>


    <div class="btn-box">
      <van-button type="info" class="btn-primary" @click="postData">确定修改密码</van-button>
    </div>
  </div>


</template>

<script>
    export default {
        name: "forget",
        components: {},
        data() {
            return {
                pwd:"",
                pwd1:"",
            }
        },
        computed: {},
        mounted: function () {
            this.isLogin();

        },
        methods: {
            postData(){
                if(this.pwd=="" || this.pwd.length<6){
                    this.$toast('密码不能小于6个字符！');
                    return false;
                }

                if(this.pwd1!=this.pwd){
                    this.$toast('重复密码不一致！');
                    return false;
                }

                let params = {
                    pwd:this.pwd,
                    pwd1:this.pwd1,
                    uppwd:1
                };
                this.$api.member.update({data:params}).then(res=>{
                    if(res.data.status == 0){
                        this.$dialog.alert(res.data.msg);
                        return false;
                    } else {
                        this.$dialog.alert({
                            message: res.data.msg
                        }).then(() => {
                            this.$router.replace({
                                path: '/user',
                                query: {
                                    redirect: this.$router.currentRoute.fullPath
                                }
                            });
                        });
                    }
                });
            }
        },
    }
</script>

<style lang="scss" scoped>
  @import "../../assets/scss/user.scss";
</style>
